<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/template.xhtml">



    <ui:define name="title"><h:outputText value="Exam Management System - EMS" /></ui:define>
    <ui:define name="header"><h:outputText value="Add Exam Question" /></ui:define>
    
    <ui:define name="content">
        <h:form id="addExamQuestion">
            <p:panelGrid columns="3">
                Module:
                <h:panelGroup>
                    <h:selectOneMenu id="module" value="#{addExamQuestionView.module.id}" title="Module" required="true" requiredMessage="Please select a module.">
                        <f:selectItems value="#{addExamQuestionView.moduleList}" var="m" itemDescription="#{m.name}" itemValue="#{m.id}" />
                    </h:selectOneMenu>
                </h:panelGroup> 
                <p:panelGrid/>
                
                Intro: <p:inputText value="#{addExamQuestionView.question.text}" size="30"/> <p:panelGrid/>
                Mark: <p:inputText value="#{addExamQuestionView.question.mark}" size="30"/> <p:panelGrid/>
                Question Tag:  
                <h:panelGroup>
                    <p:autoComplete value="#{addExamQuestionView.subjectTag}" completeMethod="#{addExamQuestionView.completeSubjectTags}" id="tags" 
                                    var="tag" itemLabel="#{tag.name}" itemValue="#{tag}" converter="tagConverter" forceSelection="true">         
                        <p:column>
                            <h:outputText value="#{tag.name}" />
                        </p:column>
                    </p:autoComplete>
                </h:panelGroup>
                <p:panelGrid/>
                
                Question Type: 
                <h:panelGroup>
                    <h:selectOneMenu id="questionType" value="#{addExamQuestionView.questionType}" title="QuestionType" required="true" requiredMessage="Please select a question type.">
                        <f:selectItems value="#{addExamQuestionView.selectQuestionTypes}" />
                    </h:selectOneMenu>
                </h:panelGroup> 
                
                <p:commandLink value="Add Question" action="#{addExamQuestionView.addQuestion()}" style="float: right" />
                
                <p:panelGrid id="displayQuestionSection" columns="3" style="width:100%" rendered="#{addExamQuestionView.questionType eq 'Essay'}" >
                    Question Text: <p:inputTextarea value="#{addExamQuestionView.questionPart.text}" autoResize="true"/> <p:panelGrid/>
                </p:panelGrid>

                <p:panelGrid id="displayQuestionSection1" columns="3" style="width:100%" rendered="#{addExamQuestionView.questionType eq 'ESSAY'}" >
                    No Essay : <p:inputTextarea value="#{addExamQuestionView.questionPart.text}" autoResize="true"/> <h:outputText id="myName" value="#{addExamQuestionView.questionType}" />
                </p:panelGrid>
                    
            </p:panelGrid>
            <br/>
            <p:panelGrid/> <p:commandButton value="Cancel" />  <p:commandButton value="Save" />
        </h:form>
        
        <br/>
        <p:commandLink value="Back To Maintain Exam Question" action="maintainQuestion"/>
        <br/>
        <p:commandLink value="Back To Home Page" action="welcome?faces-redirect=true"/>
        <br/>
    </ui:define>

</ui:composition>